package com.jia.leetCode;

import java.util.*;

/**
 * @program: Leetcode
 * @description:  https://leetcode-cn.com/problems/repeated-dna-sequences/description/
 * @author: STU756
 * @create: 2020-08-22 13:30
 */
public class Pro0187 {
    public List<String> findRepeatedDnaSequences(String s) {
        int len = 0;
        if(( len = s.length()) < 11) return new ArrayList<>();

       Set<String> set = new HashSet<>(), re = new HashSet<>();

        for(int i = 10; i <= len; i++) {
            String subStr = s.substring(i - 10, i);
            if(set.contains(subStr)) {
                re.add(subStr);
            }
            set.add(subStr);
        }
        return new ArrayList<String>(re);
    }
}
